home *** CD-ROM | disk | FTP | other *** search
-
- ; -------------------------------------------------------------
- ; Simple file-reading example, with crude string parsing...
- ; -------------------------------------------------------------
- ; Uncommented version, to show how simple the code really is...
-
- Graphics 640, 480
-
- Color 150, 150, 200
- Print ; Blank line...
- Print "Reading text from 'test.txt'..."
-
- Color 255, 255, 255
-
- ; -------------------------------------------------------------
- ; Attempt to read the file, storing the handle as 'info'...
- ; -------------------------------------------------------------
-
- info = ReadFile ("test.txt")
-
- ; -------------------------------------------------------------
- ; If the handle is valid (non-zero), process the file...
- ; -------------------------------------------------------------
-
- If info
-
- ; ---------------------------------------------------------
- ; Repeat the line-parsing until end-of-file is reached...
- ; ---------------------------------------------------------
-
- Repeat
-
- ; -----------------------------------------------------
- ; Read a line from the file and print it on screen...
- ; -----------------------------------------------------
-
- a$ = ReadLine (info)
- Print a$
-
- ; ---------------------------------------------------------
- ; Repeat above until the next line is true (end-of-file)...
- ; ---------------------------------------------------------
-
- Until Eof (info)
-
- ; ---------------------------------------------------------
- ; Close the file (important!)...
- ; ---------------------------------------------------------
-
- CloseFile info
-
- ; ---------------------------------------------------------
- ; If the file handle was invalid (zero)...
- ; ---------------------------------------------------------
-
- Else
-
- RuntimeError "Failed to read test.txt! Aborting..."
-
- EndIf
-
- ; -------------------------------------------------------------
- ; Wait for mouseclick, then quit...
- ; -------------------------------------------------------------
-
- MouseWait
- End